package com.eps.module.testdagger2_2;

import android.os.Bundle;
import android.util.Log;

import androidx.appcompat.app.AppCompatActivity;

import javax.inject.Inject;

public class SecondActivity extends AppCompatActivity {

    @Inject
    LoginViewModel loginViewModel;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
//        ((AppApplication) getApplication()).getApplicationComponent().injectX(this);

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second);

        testSingleInstance();
    }

    private void testSingleInstance() {
        Log.d("chenTest", "before set localValue: " +  loginViewModel.userRepository.getUserLocalDataSource().getValue());
        Log.d("chenTest", "before set serviceValue: "
                +  loginViewModel.userRepository.getUserRemoteDataSource().getLoginRetrofitService().getValue());
        Log.d("chenTest", "before login Value: " + loginViewModel.getValue());

        loginViewModel.userRepository.getUserLocalDataSource().setValue(10);
        loginViewModel.userRepository.getUserRemoteDataSource().getLoginRetrofitService().setValue(20);
        loginViewModel.setValue(30);
        Log.d("chenTest", "after set localValue: " +  loginViewModel.userRepository.getUserLocalDataSource().getValue());
        Log.d("chenTest", "after set serviceValue: "
                +  loginViewModel.userRepository.getUserRemoteDataSource().getLoginRetrofitService().getValue());
        Log.d("chenTest", "after login Value: " + loginViewModel.getValue());

    }
}